package cn.hesion.leetcode;
/**
 * ClassName: BuildArray <br/>
 * Description: <br/>
 * date: 2022/5/14 8:47<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import java.util.ArrayList;
import java.util.List;

/**
 * @author: hesion
 * @create: 2022-05-14 08:47
 **/
public class BuildArray {
    public List<String> buildArray(int[] target, int n) {

        ArrayList<Integer> numList = new ArrayList<>();
        List<String> operStrings = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            numList.add(i);
        }

        int len = target.length;
        int maxNum = target[len - 1];
        int minNum = Math.min(maxNum,n);

        for (int i = 0; i < minNum; i++) {
            operStrings.add("Push");
            boolean needPopFlag = true;
            for (int i1 : target) {
                if(i1 == numList.get(i)){
                    needPopFlag = false;
                }
            }
            if(needPopFlag){
                operStrings.add("Pop");
            }
        }

        return operStrings;
    }

    public static void main(String[] args) {
        List<String> strings = new BuildArray().buildArray(new int[]{1, 3}, 3);
        System.out.println(strings);
    }
}
